package com.ad.pet.app.main.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.ad.pet.R;

/**
 * 闪购推荐框
 * Created by SEELE on 2019/3/21.
 */

public class FlashBuyGoodDialog extends Dialog {
    private int screenWidth;

    public FlashBuyGoodDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        initView(context);
    }


    private void initView(Context context) {

        View view = View.inflate(context, R.layout.layout_flash_buy_good,null);
        ImageView ivClose = view.findViewById(R.id.iv_close);
        ImageView ivGood = view.findViewById(R.id.iv_good);
        TextView tvPrice = view.findViewById(R.id.tv_price);
        TextView tvOldPrice = view.findViewById(R.id.tv_old_price);
        Button btnBuy = view.findViewById(R.id.btn_buy);

        setContentView(view);
        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (screenWidth *  8/ 10); // 设置宽度
//        lp.height = (int)(lp.width*1.3);
        this.getWindow().setAttributes(lp);
        window.setGravity(Gravity.CENTER);
    }
}
